<template lang="pug">
  div( style="height:calc(100% - 10px)")
   myTable(ref="myTable" :mySeach="mySeach" :tableHeader="tableHeader" :myTableButtons="myTableButtons"  :myButtons="myButtons" seachMenth="GET" seachUrl="/estimate/teacher/list" :otherForm="otherForm")
</template>
<script>
import myTable from '../components/myTable.vue'
import { estimateTeacherDelete, teacherExport } from '@/api/educationalAdminstration'
import { mapGetters } from 'vuex'
import { downloadXls } from '@/utils'

export default {
  name: 'LeaveManagement',
  components: {
    myTable
  },
  computed: {
    ...mapGetters([
      'user'
    ])
  },
  created () {
    this.otherForm = {
      areaId: this.user.areaId
    }
  },
  data () {
    return {
      mySeach: [
        {
          label: '教师姓名',
          type: 'input',
          placeholder: '请输入姓名',
          prop: 'teacherName'
        }
      ],
      tableHeader: [
        {
          label: '教师名称',
          prop: 'staffName'
        },
        {
          label: '点评人',
          prop: 'evaluatorName'
        },
        {
          label: '点评内容',
          prop: 'teacherContent'
        },
        {
          label: '等级',
          prop: 'rating',
          type: 'rate'
        },
        {
          label: '点评日期',
          prop: 'createDate'
        }
      ],
      myTableButtons: [
        {
          label: '删除',
          click: (data) => {
            console.log('data', data)
          }
        }
      ],
      myButtons: [
        {
          label: '导出',
          type: 'warning',
          plain: true,
          click: (data) => {
            console.log('data', data)
          }
        }
      ]
    }
  },
  mounted () {
    this.myTableButtons[0].click = (data) => {
      console.log('删除', data)
      estimateTeacherDelete({ teacherEstimateId: data.row.id }).then(res => {
        console.log('res', res)
        this.$message({
          type: 'success',
          message: `删除成功!`
        })
        this.$refs.myTable.onSubmit()
      })
    }
    this.myButtons[0].click = (data) => {
      console.log('导出', data)
      this.$confirm('是否导出数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const other = this.$refs.myTable.getMyTableSearch()
        other.pageNum = 0
        other.pageSize = 10000
        teacherExport(other).then(res => {
          downloadXls(res, '教师点评.xlsx')
        })
      })
    }
  },
  methods: {
  }
}
</script>

<style scoped lang="scss">
.myAddFrom{
  padding: 20px;
  height: 100%;
  ::v-deep .el-form-item__label{
    min-width: 120px;
  }
  ::v-deep .el-form-item__error{
    margin-left: 120px;
  }
  .bottom{
    position: absolute;
    bottom: 10px;
    width: 100%;
  }
}
</style>
